package com.sky.controller.admin;

import com.itheima.utils.AliOSSUtils;
import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@Api(tags = "文件上传")
public class UploadController{

    @Autowired
    private AliOSSUtils aliOSSUtils;

    /**
     * 上传图片
     * @param file
     * @return
     * @throws IOException
     */
    @PostMapping("/admin/common/upload")
    @ApiOperation("文件上传")
    public Result upload(MultipartFile file) throws IOException {
        return Result.success(aliOSSUtils.upload(file));
    }
}
